package com.myfoon.model.cacheable;

import com.tangosol.io.ExternalizableLite;

import com.tangosol.util.ExternalizableHelper;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class EventFIFO implements ExternalizableLite {
    private long list[] = new long[15];
    private int index = 0;
    
    public EventFIFO() {
    }
    
    public void push(long l) {
        list[index] = l;
        index = index < 14 ? index+1 : 0;
    }

    public long[] getList() {
        return list;
    }

    public void readExternal(DataInput dataInput) throws IOException {
        list = (long[])ExternalizableHelper.readObject(dataInput);
        index = dataInput.readInt();
    }

    public void writeExternal(DataOutput dataOutput) throws IOException {
        ExternalizableHelper.writeObject(dataOutput, list);
        dataOutput.writeInt(index);        
    }
}
